//
//  ViewController.m
//  OC_Underlying_MP（内存分区）
//
//  Created by jianbo.pei on 2023/11/29.
//

/// MP：memory partition，内存分区

/**
 ## 参考链接
 - **[【iOS内存管理-内存的几大区域](https://blog.csdn.net/weixin_61639290/article/details/131730226)**  `csdn` November 29, 2023
 - **[iOS-底层原理 24：内存五大区](https://www.jianshu.com/p/e5a54813b93d)** `简书` November 29, 2023
 */

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = UIColor.purpleColor;
    [self test];
}

- (void)test {

    NSInteger i = 123;
    NSLog(@"i的内存地址：%p", &i);

    NSString *string = @"ABC";
    NSLog(@"string的内存地址：%p", string);
    NSLog(@"&string的内存地址：%p", &string);

    NSObject *obj = [[NSObject alloc] init];
    NSLog(@"obj的内存地址：%p", obj);
    NSLog(@"&obj的内存地址：%p", &obj);
    
}

- (void)testStack {
    int a = 10;

    NSLog(@"a == %p size == %lu",&a,sizeof(a));
    NSLog(@"方法参数 self：%p",&self);
    NSLog(@"方法参数 cmd：%p",&_cmd);
}

- (void)testHeap {
    NSObject *object1 = [NSObject new];
    NSObject *object2 = [NSObject new];
    NSLog(@"object1 = %@",object1);
    NSLog(@"object2 = %@",object2);
}

int clB;
static int bssB;
int initClB = 10;
static int initBssB = 11;
- (void)testStatic {
    NSLog(@"clA = %p", &clB);
    NSLog(@"bssB = %p", &bssB);
    NSLog(@"initClB = %p", &initClB);
    NSLog(@"initBssB = %p", &initBssB);
}




@end
